package me.zhengjie.modules.rest.intell;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import me.zhengjie.annotation.AnonymousAccess;
import me.zhengjie.modules.domain.intellectual.Qualification;
import me.zhengjie.modules.service.intell.QuaService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Api("企业资质证书api")
@RestController
@RequiredArgsConstructor
@RequestMapping("/qua")
public class QuaController {

    private final QuaService quaService;

    @ApiOperation("根据企业名称分页查询资质证书")
    @AnonymousAccess
    @GetMapping("/queryEnterpriseQuaByName")
    public Map<String,Object> queryEnterpriseQuaByName(String name, @RequestParam Integer pageNo,@RequestParam Integer pageSize){
        Map<String,Object> map=new HashMap<>();
        map.put("name",name);
        map.put("pageNo",(pageNo-1)*pageSize);
        map.put("pageSize",pageSize);
        List<Qualification> qualifications=quaService.queryEnterpriseQuaForPageByName(map);
        int total=quaService.queryEnterpriseQuaByNameToTotal(map);
        map=new HashMap<>();
        map.put("list",qualifications);
        map.put("total",total);
        return map;
    }

}
